﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Telerik.WinControls.UI;

namespace LIM
{
	public class UtilityClass
	{
        public static bool RadMultiColumnComboBoxSelectValue(RadMultiColumnComboBox comboBox, object valueToSelect)
        {
            if (comboBox == null || valueToSelect == null)
            {
                return false;
            }
            foreach (GridViewDataRowInfo row in comboBox.EditorControl.Rows)
            {                
                object value = row.Cells[comboBox.ValueMember].Value;
                if (value != null && value.Equals(valueToSelect))
                {
                    comboBox.EditorControl.CurrentRow = row;
                    object displayValue = row.Cells[comboBox.DisplayMember].Value;
                    if (displayValue != null)
                    {
                        comboBox.MultiColumnComboBoxElement.TextBoxElement.TextBoxItem.Text = displayValue.ToString();
                    }
                    return true;
                }
            }
            return false;
        }  
	}
}
